/**
 * 网易云音乐API(获取歌手专辑列表)
 * GET http://music.163.com/api/artist/albums/[artist_id]/
	其中artist_id用歌手id替换
	参数:
	offset: 偏移数量，用于分页
	limit: 返回数量
 */

var http = require('http');
var queryString = require('querystring');



var  artist_id = '3683'; //李宗盛


var options = {  
        method: "Get",  
        host: "music.163.com",
        post : 80,
        path: "/api/artist/albums/" + artist_id + '?offset=1&limit=5',  
        headers: { 
        	"cookie":'appver=2.0.2',
        	"referer":'http://music.163.com',
            "Content-Type": 'application/x-www-form-urlencoded'
        }  
    };  



var req = http.request(options, function(res) {
	  console.log('状态码：');
//	  console.dir(res.statusCode,{colors:true});
	  console.dir(res.statusCode);
	  console.log('请求头：');
//	  console.dir(res.headers,{colors:true});
	  console.dir(res.headers);
	  var data = '';
	  res.setEncoding('utf-8');
	  res.on('data', function (chunk) {
//		  buffer.concat(chunk);
		  data += chunk;
	  }).on('end',function() {
//		  console.log(str);
		  console.log('返回数据：');
		  console.dir(JSON.parse(data),{depth:10});
//		  console.dir(JSON.parse(data),{depth:10,colors:true});
	  });
	});

	req.on('error', function(e) {
	  console.log('problem with request: ' + e.message);
	});

	// write data to request body
	req.end();